'use strict';
exports = module.exports = function ($scope){
    ///////////////////////////////////////////////////////////////
    $scope.doSearchOnRealTimeContent = '';
    $scope.doSearchOnRealTimeFlag = '';
    $scope.doSearchOnRealTime = _.debounce(function(){
        var time = (new Date()).getTime();
        $scope.doSearchOnRealTimeFlag = "获取内容" + time;
    }, 1e3, {
        trailing: true
    })
    ///////////////////////////////////////////////////////////////
    $scope.doSubmitOnSomeTimeFlag = '';
    $scope.doSubmitOnSomeTime = _.throttle(function(){
        var time = (new Date()).getTime();
        $scope.doSubmitOnSomeTimeFlag = "获取内容" + time;
    }, 5e2, {
        trailing: false,
        leading: true
    })
    ///////////////////////////////////////////////////////////////
    $scope.test = function(){
        var func1 = _.debounce(function(){
            var time = (new Date()).getTime() - curentTime1;
            $("#debounceTest1 > div").append("<b style=\"background:green;\">" + time + "</b>")
        }, 5e2, {
            maxWait: 3e3,
            trailing: true
        })
        var n1= 1;
        var curentTime1 = 0;
        var interval1 = setInterval(function(){
            if(!curentTime1){curentTime1 = (new Date()).getTime();}
            var time = (new Date()).getTime() - curentTime1;
            $("#debounceTest1 > div").append("<b>" + time + "</b>")
            func1();
            if( n1 >= 15 ) clearInterval(interval1);
            n1 ++;
        }, 4e2);
        ///////////////////////////////////////////////////////////////
        var func2 = _.debounce(function(){
            var time = (new Date()).getTime() - curentTime2;
            $("#debounceTest2 > div").append("<b style=\"background:green;\">" + time + "</b>")
        }, 5e2, {
            maxWait: 3e3,
            trailing: false,
            leading: true
        })
        var n2 = 1;
        var curentTime2 = 0;
        var interval2 = setInterval(function(){
            if(!curentTime2){curentTime2 = (new Date()).getTime();}
            var time = (new Date()).getTime() - curentTime2;
            $("#debounceTest2 > div").append("<b>" + time + "</b>")
            func2();
            if( n2 >= 15 ) clearInterval(interval2);
            n2 ++;
        }, 4e2);
        ///////////////////////////////////////////////////////////////
        var func3 = _.debounce(function(){
            var time = (new Date()).getTime() - curentTime3;
            $("#debounceTest3 > div").append("<b style=\"background:green;\">" + time + "</b>")
        }, 5e2, {
            maxWait: 3e3,
            trailing: true,
            leading: true
        })
        var n3 = 1;
        var curentTime3 = 0;
        var interval3 = setInterval(function(){
            if(!curentTime3){curentTime3 = (new Date()).getTime();}
            var time = (new Date()).getTime() - curentTime2;
            $("#debounceTest3 > div").append("<b>" + time + "</b>")
            func3();
            if( n3 >= 15 ) clearInterval(interval3);
            n3 ++;
        }, 4e2);
        ///////////////////////////////////////////////////////////////
        var func4 = _.throttle(function(){
            var time = (new Date()).getTime() - curentTime4;
            $("#debounceTest4 > div").append("<b style=\"background:green;\">" + time + "</b>")
        }, 3e3, {
            trailing: true,
            leading: true
        })
        var n4 = 1;
        var curentTime4 = 0;
        var interval4 = setInterval(function(){
            if(!curentTime4){curentTime4 = (new Date()).getTime();}
            var time = (new Date()).getTime() - curentTime2;
            $("#debounceTest4 > div").append("<b>" + time + "</b>")
            func4();
            if( n4 >= 10 ) clearInterval(interval4);
            n4 ++;
        }, 4e2);
        ///////////////////////////////////////////////////////////////
        var func5 = _.throttle(function(){
            var time = (new Date()).getTime() - curentTime5;
            $("#debounceTest5 > div").append("<b style=\"background:green;\">" + time + "</b>")
        }, 3e3, {
            trailing: true,
            leading: false
        })
        var n5 = 1;
        var curentTime5 = 0;
        var interval5 = setInterval(function(){
            if(!curentTime5){curentTime5 = (new Date()).getTime();}
            var time = (new Date()).getTime() - curentTime2;
            $("#debounceTest5 > div").append("<b>" + time + "</b>")
            func5();
            if( n5 >= 10 ) clearInterval(interval5);
            n5 ++;
        }, 4e2);
        ///////////////////////////////////////////////////////////////
        var func6 = _.throttle(function(){
            var time = (new Date()).getTime() - curentTime6;
            $("#debounceTest6 > div").append("<b style=\"background:green;\">" + time + "</b>")
        }, 3e3, {
            trailing: false,
            leading: true
        })
        var n6 = 1;
        var curentTime6 = 0;
        var interval6 = setInterval(function(){
            if(!curentTime6){curentTime6 = (new Date()).getTime();}
            var time = (new Date()).getTime() - curentTime2;
            $("#debounceTest6 > div").append("<b>" + time + "</b>")
            func6();
            if( n6 >= 10 ) clearInterval(interval6);
            n6 ++;
        }, 4e2);
    };
}
